package com.ecommerce.onion;

import com.ecommerce.onion.application.cli.CliOrderController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

/**
 * @packageName: com.ecommerce.onion（根包）
 * @className: DomainLayerApplication(领域层应用)
 * @description: 采用领域服务的方式
 * @author: luds
 * @version: v1.0
 * @date: 2021-03/26
 */
@SpringBootApplication
public class DomainLayerApplication implements CommandLineRunner {

    public static void main(final String[] args) {
        SpringApplication application = new SpringApplication(DomainLayerApplication.class);
        // 取消注释以仅运行控制台应用程序
        // application.setWebApplicationType(WebApplicationType.NONE);
        application.run(args);
    }

    @Autowired
    public CliOrderController orderController;

    @Autowired
    public ConfigurableApplicationContext context;

    @Override
    public void run(String... args) throws Exception {
        orderController.createCompleteOrder();
        orderController.createIncompleteOrder();
        // 在执行完成时取消注释以停止上下文
        // context.close();
    }
}
